# -*- coding: utf-8 -*-
"""
 @Time    : 2021/2/3 下午4:05
 @Author  : tgy
 
"""
import json

class Person:
    def __init__(self,dict_data):
        self.__dict__.update(dict(dict_data))


def get_attr(obj):
    ...
    res = {}
    for k in sorted(dir(obj)):
        ...
        if k.startswith('_') or k.startswith('__'):
            continue
        res[k] = getattr(obj, k)
    return res

def test01():
    ...
    person = {'name': '112', 'age': 21,'dog':{'name':'tony'}}

    per_str = json.dumps(person,indent=4)
    print(per_str)

    per = json.loads(per_str, object_pairs_hook=Person)

    # print(vars(per))
    # print(per.name)
    print(get_attr(per))


def test02():
    ...



if __name__ == '__main__':
    ...
    test01()